//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.sixth.controller;


import com.sixth.entity.Department;
import com.sixth.entity.Staff;
import com.sixth.service.DepartmentService;
import com.sixth.service.TypeService;
import com.sixth.util.CommonResult;
import com.sixth.util.LayTab;
import com.sixth.util.TableLayUi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping({"/dept"})
public class DepartmentController {
    @Autowired
    private DepartmentService departmentService;
    @Autowired
    private TypeService typeService;
    //获取全部部门
    @RequestMapping("/listByCondition")
    public TableLayUi listByCondition(int page, int limit) {
        return departmentService.findDepartmentByCondition(page, limit);
    }
    //获取
    @RequestMapping("getAllType")
    public List<Map> getAllType(){
        return typeService.getAllType();
    }

    @RequestMapping("/addOrUpdateDept")
    public CommonResult update(Department department) {
        if(department.getDeptid()!=null){
            return departmentService.update(department);
        }else {
            return departmentService.insert(department);
        }
    }
    @RequestMapping("/delete")
    public CommonResult delete(Integer deptid) {
        return departmentService.delete(deptid);
    }

    //当前点击行的数据
    @RequestMapping("/sel")
    public LayTab sel(Staff staff,Integer deptid){

        return     departmentService.sel(staff,deptid);
    }
    /*部门名校验*/
    @RequestMapping("getDeptName")
    public CommonResult getDeptName(String deptname) {
        CommonResult deptName = departmentService.getDeptName(deptname);
        return deptName;
    }
}

